<template>
    <div class="identity-content">
        <div class="organ-content" v-if="companyInfo">
            <h4>机构信息</h4>
            <div class="organ-info">
                <img src="../../assets/images/company.png" class="logo-defalut"/>                    
                <div class="organ-left">
                    <div class="info-item">                   
                        <span class="info-label">机构名称：</span><span class="info-01">{{ companyInfo.companyName }}</span>
                    </div>
                     <div class="info-item">                    
                        <span class="info-label">机构社会统一信用信息代码：</span><span class="info-01">{{ companyInfo.creditNo }}</span>
                    </div>
                     <div class="info-item">                   
                        <span class="info-label">营业执照注册号：</span><span class="info-01">{{ companyInfo.licenseNo }}</span>
                    </div>
                </div>
                <div class="line-style"></div>
                <div class="organ-right" v-if="companyInfo">
                    <div class="info-item">                   
                        <span class="info-label">法定代表人身份：</span><span class="info-01">{{ companyInfo.juridicalPerson }}</span>
                    </div>
                    <div class="info-item">                   
                        <span class="info-label">法定代表人身份证号：</span><span class="info-01">{{ companyInfo.juridicalPersonIdcard }}</span>
                    </div>
                </div>
            </div>
        </div>    
        <div class="person-content">
            <h4>数字身份</h4>
            <div class="dow" @click="dowFn(companyInfo.cidUrl)">
                下载私钥文件<el-icon><Download /></el-icon>
            </div>
        </div>
        <div class="person-content">
            <h4>个人信息</h4>
            <div class="person-info">
                <img :src="userAvatar" class="logo-defalut"/>                    
                <div class="info-02">
                    <div class="info-item">                   
                        <span class="info-label">姓名：</span><span class="info-01">{{ userInfo.name }}</span>
                    </div>
                    <div class="info-item">                   
                        <span class="info-label">手机号：</span><span class="info-01">{{ userInfo.telephone }}</span>
                    </div>
                </div>
            </div>

        </div>
    </div>
</template>
<script setup lang="ts">
    // import { commonImgPicture } from '@/ajax';
import { getAppspaceCompany } from '@/ajax/index';
import userDefaultImg from '@/assets/images/userDefault.png';
import { useRouter } from 'vue-router';
import { useStore } from 'vuex';
import { Download } from '@element-plus/icons-vue'
	const { proxy } = getCurrentInstance() as any;
    // 路由
	const router = useRouter();
    // 待实名认证页面
    const handleHref = () => {
        router.push("/noCertifiedIndex")
    }
    
    const store = useStore()
    const userInfo = computed(() => store.state.user.userInfo)
    const userAvatar = ref(userDefaultImg);
    const companyInfo = ref()
    const dowFn = (url:string)=>{
        window.open(url)
    }

	const created = async () => {
        const companyId = userInfo.value.companyId || 0
        if (!companyId) {
            handleHref()
            return
        }
        await getAppspaceCompany({id: companyId}).then(async (res: any) => {
			if (res.succ) {
                companyInfo.value = res.content || false
            }
        })

        // if (userInfo.value.profile) {
		// 	const res = await commonImgPicture(userInfo.value.profile);
		// 	if (res.succ) {
		// 		userAvatar.value = res.content;
		// 	}
		// }
	};
	created();
</script>
<style scoped lang="scss">
    .identity-content{
        padding: 0 20px;
    }
    h4{
        font-size: 16px;
        font-weight: bold;
        padding-bottom: 20px;
    }
    .logo-defalut{
        width: 120px;
        height: 120px;
        border-radius: 4px;
    }
    .organ-content{
        margin-bottom: 100px;
        .organ-info{
            display: flex;
           
            .info-item{
                padding-bottom: 10px;
                .info-01{
                    display: inline-block;
                    width: 50%;
                    text-align: right;
                }
                .info-label{
                    width: 50%;                    
                    display: inline-block;
                }
            }
            .organ-left{
                width: 500px;
                padding: 20px 30px 20px 20px;
                // border-right: 1px solid #DBDCDD;
            }
            .line-style{
                width: 1px;
                height: 82px;
                background: #DBDCDD;
                margin-top: 18px;
            }
            .organ-right{
                width: 500px;
                padding: 20px 30px 20px 37px;
            }
        }
    }
    .person-content{
        .dow{
            margin: 20px 0;
            height: 40px;
            line-height: 40px; 
            width: 300px;
            text-align: center;
            cursor: pointer;
            text-align: center;
            .el-icon{
                margin-left: 5px;
                vertical-align: middle;
            }
            &:hover{
                opacity: 0.7;
            }
        }
        .person-info{
            display: flex;
            .info-02{
                width: 300px;
                padding: 20px;
            }
            .info-item{
                padding-bottom: 10px;

                .info-01{
                    display: inline-block;
                    width: 60%;
                    text-align: right;
                }
                .info-label{
                    width: 40%;                    
                    display: inline-block;
                }
            }
        }
        
    }
</style>
